#ifndef __IANGELS_UGRAPH_GRAPH_H__
#define __IANGELS_UGRAPH_GRAPH_H__

#include "ugraph/tensor.h"
#include "status.h"

#include <string>
#include <vector>
#include <map>

namespace iangels {

struct uEdge {
    struct Attributes {

    };
}; // class uEdge

class uNode {
public:
    enum Type {
        TYPE_CONSTANT_TENSOR,
        TYPE_OPERATOR_CPU,
        TYPE_OPERATOR_CUDA,
    }; // enum Type

    struct Attributes {
        Type type;
        std::string id;
        std::vector<LazyDynamicTensor> inputs;
        std::vector<LazyDynamicTensor> outputs;
        std::map<std::string, LazyDynamicTensor> parameters;
    }; // struct Attributes

    static uNode make(Attributes& attris);

protected:
    uNode(const std::string& name): name_(name) {}

private:
    std::string name_;
}; // class uNode

class uGraph {
public:
    struct Attributes {
        Attributes() {}
    }; // struct Attributes

    uGraph() {}
    uGraph(const Attributes& attris) : attris_(attris) {}

    struct OrderQueue {
        std::vector<uNode*> nodes;
    }; // struct OrderQueue

    // 创建图
    static uGraph& make(const Attributes& attris);
    // 创建节点
    uNode& make_node(const uNode::Attributes& attris);
    // 创建边
    uEdge& make_edge(const uEdge::Attributes& attris);
    const struct Attributes& attributes() const { return attris_; }

    Ret Analyis();
    Ret Transform();


private:
    Attributes attris_;

}; // class uGraph

} // namespace iangels

#endif // __IANGELS_UGRAPH_GRAPH_H__